import { request } from '@/utils/request'

enum API {
  // 获取分类列表
  WARE_SKU_URL = '/api/ware/waresku/list',
  // 删除库存
  WARE_SKU_DELETE_URL = '/api/ware/waresku/delete',
  // UPDATE获取信息
  WARE_SKU_INFO_LIST = '/api/ware/waresku/info',
  // UPDATE提交
  WARE_SKU_UPDATE_COMMIT = '/api/ware/waresku',
}

// 获取分类信息
export const reqWareSkuInfoList = (
  page: number,
  limit: number,
  skuId: string,
  wareId: string,
) =>
  request.get<any, any>(
    API.WARE_SKU_URL +
      `?page=${page}&limit=${limit}&skuId=${skuId}&wareId=${wareId}`,
  )

// 删除仓库
export const reqWareSkuDelete = (ids: any) => {
  return request.post<any, any>(API.WARE_SKU_DELETE_URL, ids)
}

// UPDATE获取信息
export const reqWareSkuInfo = (id: number) =>
  request.get<any, any>(API.WARE_SKU_INFO_LIST + `/${id}`)

// UPDATE提交
export const reqWareSkuUpdateCommit = (
  type: string,
  id: number,
  skuId: string,
  wareId: string,
  stock: number,
  skuName: string,
  stockLocked: number,
) => {
  if (type == 'save') {
    return request.post<any, any>(API.WARE_SKU_UPDATE_COMMIT + `/${type}`, {
      skuId,
      wareId,
      stock,
      skuName,
      stockLocked,
    })
  } else {
    return request.post<any, any>(API.WARE_SKU_UPDATE_COMMIT + `/${type}`, {
      id,
      skuId,
      wareId,
      stock,
      skuName,
      stockLocked,
    })
  }
}
